/**
 * a标签下载
 * @param {url或者Blob对象} blobData
 * @param {String} filename
 */
export function downloadByA(blobData: Blob, filename = 'data') {
  const link = document.createElement('a')
  const body = document.querySelector('body') as HTMLBodyElement
  const url =
    blobData instanceof Blob ? window.URL.createObjectURL(blobData) : blobData

  link.href = url
  link.download = filename
  link.style.display = 'none'

  body.appendChild(link)
  link.click()

  body.removeChild(link)
  window.URL.revokeObjectURL(url)
}
